<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.css"/>
<link rel="stylesheet" href="<%=basePath %>css/buttons.css" />
<script type="text/javascript" src="<%=basePath %>js/WdatePicker.js" ></script>
<!-- 城市选择js -->
<script type="text/javascript" src="<%=basePath %>js/selCity/cityList.js" ></script>
<!-- 表单验证js -->
<script src="<%=basePath %>js/Form validation/jquery-1.4.4.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="<%=basePath %>css/Form validation/validator.css"></link>
<script src="<%=basePath %>js/Form validation/formValidator-4.0.1.js" type="text/javascript" charset="UTF-8"></script>
<script src="<%=basePath %>js/Form validation/formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript">
$(document).ready(function(){
	/* $("#fileUpload").click(function() {
        var $form = $("form2");
        $.ajax({
            cache: true,
            type: "POST",
            url: $form.attr("action"),	//提交的url
            data: $form.serialize(),
            async: false,
            success: function (data) {
            	alert("1111");
                location.reload();
            },
            error: function (request) {
                alert("2222");
                location.reload();
            }
        });
    });  */
	$.formValidator.initConfig({ formID: "form1", onError: function () { alert("校验没有通过，具体错误请看错误提示！") } });
	$("#trainnumber").formValidator({onShow:"请输入车次",onFocus:"长度6-20个字符!",onCorrect:"输入正确！"}).inputValidator({min:6,max:20,empty:{leftEmpty:false,rightEmpty:false,emptyError:"车次两边不能有空符号!"},onError:"车次不能为空或长度不符，请检查！"});
 	$("#startstation").formValidator({onShow:"请选择始发地",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#endstation").formValidator({onShow:"请选择终点站",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#starttime").formValidator({onShow:"请选择发车时间",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#endtime").formValidator({onShow:"请选择到达时间",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#puttickettime").formValidator({onShow:"请选择放票时间",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#viastaion1").formValidator({onShow:"请选择中途停靠站",onFocus:"中途停靠站可不选",onCorrect:"选择正确！"}).inputValidator({empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#viastaion2").formValidator({onShow:"请选择中途停靠站",onFocus:"中途停靠站可不选",onCorrect:"选择正确！"}).inputValidator({empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#viastaion3").formValidator({onShow:"请选择中途停靠站",onFocus:"中途停靠站可不选",onCorrect:"选择正确！"}).inputValidator({empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#viastaion4").formValidator({onShow:"请选择中途停靠站",onFocus:"中途停靠站可不选",onCorrect:"选择正确！"}).inputValidator({empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#viastaion5").formValidator({onShow:"请选择中途停靠站",onFocus:"中途停靠站可不选",onCorrect:"选择正确！"}).inputValidator({empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#total").formValidator({onShow:"请输入车票数",onCorrect:"输入正确！"}).regexValidator({regExp:"intege1",dataType:"enum",onError:"车票数格式不正确，请检查！"});
 	$("#exit").click(function(){
		location.href = "<%=basePath %>index.jsp";
	});
});
</script>
<script type="text/javascript">
function  msg(){
	document.getElementById("txtFile").value = document.getElementById("f").value;
}
</script>
<body onload="">
	<br>
	<center>
		<form action="<%=basePath%>file/uploadXlsfile" method="post" enctype="multipart/form-data" id="form2">
			<table width="700" cellpadding="0" border="0">
				<tr>
					<td width="200" align="right">
						选择文件：
					</td>
					<td width="200">
						<input type="file" id="f" name="trainFile" size="50"/>
					</td>
					<td width="200">
						 <input type="submit" id="fileUpload" value="上传文件" class="button button-pill button-primary" style="width:100px;height:30px;"
						 onclick="msg()"/>
						 <label><font color="red" size="2">${msg }</font></label>
						 <br>
						 <input type="text" id="txtFile" name="txtFile" value="" >
					</td>
				</tr>
			</table>
		</form>
		<br><br>
		<form action="<%=basePath%>trainInfo/add" method="post" role="form" id="form1">
			<table width="700" cellpadding="0" border="0">
				<tr>
					<td align="right" width="300">车次：</td>
					<td width="200"><input id="trainnumber" name="trainnumber" class="form-control" style="width:160px;height:25px;"></td>
					<td ><div id="trainnumberTip" style="width:250px"></div></td>	
				</tr>	
				<tr>
					<td align="right">始发地：</td>
					<td><input id="startstation" name="startstation" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" value="" ></td>
					<td><div id="startstationTip" style="width:250px"></div></td>	
				</tr>
				<tr>
					<td align="right">终点站：</td>
					<td><input id="endstation" name="endstation" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" ></td>
					<td><div id="endstationTip" style="width:250px"></div></td>	
				</tr>
				<tr>
					<td align="right">发车时间：</td>
					<td><input id="starttime" name="starttime" type="text"  class="form-control" style="width:160px;height:25px;" onclick="WdatePicker( {el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'} )" readonly></td>
					<td><div id="starttimeTip" style="width:250px"></div></td>
				</tr>
				<tr>
					<td align="right">到达时间：</td>
					<td><input id="endtime" name="endtime" type="text"  class="form-control" style="width:160px;height:25px;" onclick="WdatePicker( {el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'} )" readonly></td>
					<td><div id="endtimeTip" style="width:250px"></div></td>
				</tr>
				<tr>
					<td align="right">放票时间：</td>
					<td><input id="puttickettime" name="puttickettime" type="text"  class="form-control" style="width:160px;height:25px;" onclick="WdatePicker( {el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'} )" readonly></td>
					<td><div id="puttickettimeTip" style="width:250px"></td>
				</tr>
				<tr>
					<td align="right">途经站1：</td>
					<td><input id="viastaion1" name="viastaion1" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" ></td>
					<td><div id="viastaion1Tip" style="width:250px"></td>
				</tr>
				<tr>
					<td align="right">途经站2：</td>
					<td><input id="viastaion2" name="viastaion2" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" ></td>
					<td><div id="viastaion2Tip" style="width:250px"></td>
				</tr>
				<tr>
					<td align="right">途经站3：</td>
					<td><input id="viastaion3" name="viastaion3" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" ></td>
					<td><div id="viastaion3Tip" style="width:250px"></td>
				</tr>
				<tr>
					<td align="right">途经站4：</td>
					<td><input id="viastaion4" name="viastaion4" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" ></td>
					<td><div id="viastaion4Tip" style="width:250px"></td>
				</tr>
				<tr>
					<td align="right">途经站5：</td>
					<td><input id="viastaion5" name="viastaion5" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" ></td>
					<td><div id="viastaion5Tip" style="width:250px"></td>
				</tr>
				<tr>
					<td align="right">车厢数量：</td>
					<td>
						<select id="compartmentsnumber" name="compartmentsnumber" class="form-control" style="width:160px;height:30px;">
							<option value="1">1</option>
							<option value="2">2</option>
							<option value="3">3</option>
							<option value="4">4</option>
							<option value="5">5</option>
							<option value="6">6</option>
							<option value="7">7</option>
							<option value="8">8</option>
							<option value="9">9</option>
							<option value="10">10</option>
						</select>
					</td>
					<td></td>
				</tr>
				<tr>
					<td align="right">上铺座位数：</td>
					<td>
						<select id="spnumber" name="spnumber" class="form-control" style="width:160px;height:30px;">
							<option value="100">100</option>
							<option value="120">120</option>
							<option value="140">140</option>
							<option value="160">160</option>
							<option value="180">180</option>
							<option value="200">200</option>
						</select>
					</td>
					<td></td>
				</tr>
				<tr>
					<td align="right">中铺座位数：</td>
					<td>
						<select id="zpnumber" name="zpnumber" class="form-control" style="width:160px;height:30px;">
							<option value="100">100</option>
							<option value="120">120</option>
							<option value="140">140</option>
							<option value="160">160</option>
							<option value="180">180</option>
							<option value="200">200</option>
						</select>
					</td>
					<td></td>
				</tr>
				<tr>
					<td align="right">下铺座位数：</td>
					<td>
						<select id="xpnumber" name="xpnumber" class="form-control" style="width:160px;height:30px;">
							<option value="100">100</option>
							<option value="120">120</option>
							<option value="140">140</option>
							<option value="160">160</option>
							<option value="180">180</option>
							<option value="200">200</option>
						</select>
					</td>
					<td></td>
				</tr>
				<tr>
					<td align="right">票价：</td>
					<td>
						<input id="price" name="price" class="form-control" style="width:160px;height:25px;">
					</td>
					<td></td>
				</tr>
				<tr>
					<td colspan="4" align="center">
						<br><input type="submit" value="保存" id="reg" onclick="" class="button button-pill button-primary" style="width:140px;height:40px;">
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="button" value="返回" id="exit" 
						class="button button-pill button-primary" style="width:140px;height:40px;">
					</td>
				</tr>
			</table>
		</form>
	</center>
</body>
</html>